import {take, call, put, fork, cancel} from 'redux-saga/effects';
import AuthManager from '../services/auth'
import * as Actions from '../actions/index'
import * as Types from '../actions/ActionTypes.js'
import * as api from '../services/upload';
import {message} from 'antd';
import callServiceApi from './utils';

function* watchUploadListQuery() {
  while (true) {
    const {payload} = yield take(Types.UPLOAD_LIST_QUERY.REQUEST);
    yield fork(uploadListQuery, payload);
  }
}

function* watchUploadDetailQuery() {
  while (true) {
    const {payload} = yield take(Types.UPLOAD_DETAIL_QUERY.REQUEST);
    yield fork(uploadDetailQuery, payload);
  }
}

function* uploadListQuery(payload) {
  yield fork(callServiceApi, Actions.uploadListQuery, api.uploadListQuery, payload);
}

function* uploadDetailQuery(id) {
  yield fork(callServiceApi, Actions.uploadDetailQuery, api.uploadDetailQuery, id);
}

export default function*() {
  yield [
    fork(watchUploadListQuery),
    fork(watchUploadDetailQuery),

  ];
}
